<template>
  <div>
    <div v-if="listview.length>0" class="boxstyle">
      <div class="list" v-for="(item) in listview" :key="item.id">
      <router-link   :to="{ name:'fitdetail',params:{fit_id:item.id} }" 
      href="#"  >
        <UserTitle :icon="item.icon" :user="item.user" :time="item.time" :city="item.city"/>
        <img :src="item.img" alt>
        <p class="text">{{item.desc}}</p>
       </router-link>
        <ul>
          <li class="first" @click="changecolor">
            <i :class="['iconfont', {icolor:flag}]">&#xe613;</i>
            {{item.like}}
          </li>
          <li   class="second">
            <i class="iconfont">&#xf003b;</i>
            {{item.comment}}
          </li>
        </ul>      
     </div>
    </div>
    <div v-else>正在加载数据...</div>
  </div>
</template>

<script>
import UserTitle from "./UserTitle";

export default {
  name: "FitRightsListView",
  data() {
    return {
     flag:false, 
    };
  },
    components: {
    UserTitle
  },
  props: {
    listview: {
      type: Array,
      default: function() {
        return [];
      }
    }
  },
  methods: {
    changecolor(){
      this.flag =! this.flag
    }
  },
  mounted() {
    console.log(this.listview);
  }
};
</script>
<style scoped lang="less">
.boxstyle {
  overflow: auto;
  // width: 100%;
}
.icolor{
  color:red;
  // background-color: red
}
.list {
  background-color: white;
  margin-bottom: 10px;
  display: block;
  padding: 0 10px;
  .user {
    overflow: hidden;
    /* display: table-cell; */
    vertical-align: middle;
    padding: 5px 0;
    img {
      width: 2rem;
      float: left;

      position: relative;
      top: 0.2rem;
    }
    .center {
      float: left;
      margin-left: 0.5rem;
      p {
        font-size: 0.8rem;
      }
      span {
        font-size: 0.7rem;
        color: #a8a9a9;
      }
    }
    .time {
      float: right;
      font-size: 0.8rem;
      line-height: 2rem;
    }
  }
  img {
    width: 100%;
  }
  .text {
    font-size: 0.7rem;
    // margin-top: 10px;
    letter-spacing: 2px;
    line-height: 1.3rem;
    padding:10px 0;
    border-bottom: 1px solid #dcdcdc; 
  }
  ul {
    overflow:hidden; 
    li {
      list-style: none;
      float: left;
      width: 49%;
      text-align: center;
      font-size: 0.7rem;
      margin: 10px 0;
    }
  }
}
.first {
  border-right: 1px solid #a8a9a9;
}
.second {
  float: right;
}
// 只能有一个class会覆盖之前的
.clear-padding {
  margin: 0;
  margin-top: 10px;
}
</style>